#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QMouseEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::mousePressEvent(QMouseEvent *event)
{
    //鼠标不同的键按下
    if(event->button() == Qt::LeftButton)
        qDebug() << "鼠标左键按下" ;
    else if (event->button() == Qt::MidButton) {
        qDebug() << "鼠标中键按下" ;
    }
    else if (event->button() == Qt::RightButton) {
        qDebug() << "鼠标右键按下" ;
    }
}

void Widget::mouseReleaseEvent(QMouseEvent *event)
{
    //鼠标不同的键按下
    if(event->button() == Qt::LeftButton)
        qDebug() << "鼠标左键释放" ;
    else if (event->button() == Qt::MidButton) {
        qDebug() << "鼠标中键释放" ;
    }
    else if (event->button() == Qt::RightButton) {
        qDebug() << "鼠标右键释放" ;
    }
}

